#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
using namespace std;

class Person
{
public:
    Person(string name, int score = 0) : m_score(score), m_name(name) {}

    string m_name;
    int m_score;
};

void printVec(const vector<Person> &v)
{
    for (vector<Person>::const_iterator it = v.begin(); it != v.end(); ++it)
    {
        cout << "name" << it->m_name << "score" << it->m_score << endl;
    }
}
void setScore(vector<Person> &v)
{
    for (vector<Person>::iterator it = v.begin(); it != v.end(); ++it)
    {
        deque<int> d;
        for (int i = 0; i < 10; ++i)
        {
            d.push_back(rand());
        }

        sort(d.begin(), d.end());

        d.pop_back();
        d.pop_front();

        int avg = d[0] + d[1] + d[2];
        avg /= 3;

        it->m_score=avg;
    }
}

int main()
{
    // 创建5个选手
    vector<Person> v;
    v.push_back(Person("a"));
    v.push_back(Person("b"));
    v.push_back(Person("c"));
    v.push_back(Person("d"));
    v.push_back(Person("e"));

    setScore(v);

    printVec(v);

}
